home *** CD-ROM | disk | FTP | other *** search
/ Apple Reference & Present…nuary (Partner) - Disc 1 / The Apple Reference and Presentations Library (Disc 1)(January 1994).iso / Frame Technology / US English / FrameMaker 4-68K / Samples / PostScript / BigRGB.ps next >
Text File  |  1994-03-22  |  4KB  |  155 lines

  1. % BigRGB.ps
  2. % Fills a FrameMaker text column with a string.
  3. % Options: color filled, color outlined, or both
  4. %
  5. % This program does more than BigFill.ps and BigLine.ps combined.
  6. %
  7. % Modification Log:
  8. %    Dec 8, 1988     Added /E mode and /CE corner
  9. %    Dec 14, 1990     Added color
  10. %    Aug 20, 1991     Merged Fill and Line functions
  11. %    Jul 22, 1992     Changed to accept both gray and RGB values
  12. %    Sep 14, 1992     Edited comments to match SpecEffects
  13. %
  14. % Required Arguments:
  15. %    (string) /font /fillmode rotation /alignment fillcolor linecolor linewidth
  16. %
  17. %    1 = string in parenthesis    ie. (MYSTRING)
  18. %    2 = font desired: /font      ie.  /Times-Roman
  19. %    3 = fill mode
  20. %        where /W = fill width, /H = fill height, 
  21. %        /B = fill both, /E = fill either (whichever
  22. %        is smaller)
  23. %    4 = rotation (from -180 to +180)
  24. %        where positive = counterclockwise, 
  25. %        negative = clockwise
  26. %    5 = alignment (with text column)
  27. %        where /LL = lower left, /LR = lower right, 
  28. %        /UL = upper left, /UR = upper right, 
  29. %        /CE = centered in text column
  30. %    6 = fill color
  31. %        formats:    [ Red Green Blue ] or gray
  32. %        [] means no fill, [0 0 0] or 0 means black
  33. %        from 0 to 1 where 0 = dimmist , 1 = brightest
  34. %    7 = line color
  35. %        formats:    [ Red Green Blue ] or gray
  36. %        [] means no outline, [1 1 1] or 1 means white
  37. %    8 = line width (in points)
  38. %        if negative number, prints outline on top of fill
  39. %
  40. % Sample Usage:
  41. %    % To write the word in turqoise with 2 point black outline
  42. %   % at 45 degree centered in the text column.
  43. %    (Hello) /Times-Roman /E 45 /CE [ .25 .8785 .8157 ] 0 2
  44. %    #include "BigRGB.ps"
  45. %
  46. % If you are familiar with BigFill.ps and BigLine.ps from previous releases,
  47. % here are the equivalent calls to get the same results:
  48. %
  49. %    % 45 degree text filled with 50% gray
  50. %    (Hello) /Times-Roman /B 45 /LL 0.5
  51. %    #include "BigFill.ps"
  52. %
  53. % is equivalent to
  54. %
  55. %    % 45 degree text filled with 50% gray and no outline
  56. %    (Hello) /Times-Roman /B 45 /LL 0.5 [] 0
  57. %    #include "BigRGB.ps"
  58. %
  59. % while
  60. %
  61. %    % 45 degree text in black 2 point outline 
  62. %    (Hello) /Times-Roman /B 45 /LL 2
  63. %    #include "BigLine.ps"
  64. %
  65. % is equivalent to
  66. %
  67. %    % 45 degree text in black 2 point outline and no fill
  68. %    (Hello) /Times-Roman /B 45 /LL [] 0 2
  69. %    #include "BigRGB.ps"
  70. %
  71. % RGB values of several colors can be found in
  72. %    /usr/lib/X11/rgb.txt        for X Windows
  73. %    /usr/openwin/lib/rgb.txt    for Sun Open Windows
  74. %    Divide the values by 255 to normalize them between 0 and 1.
  75.  
  76. /thick exch def
  77. dup type /arraytype ne {
  78.     /drawline true def
  79.     /lineblue 1 index def
  80.     /linegreen 1 index def
  81.     /linered exch def
  82. }{
  83.     dup length 3 eq /drawline 1 index def {
  84.         aload pop
  85.         /lineblue exch def
  86.         /linegreen exch def
  87.         /linered exch def
  88.     }{     pop
  89.     } ifelse
  90. } ifelse
  91. dup type /arraytype ne {
  92.     /drawfill true def
  93.     /fillblue 1 index def
  94.     /fillgreen 1 index def
  95.     /fillred exch def
  96. }{
  97.     dup length 3 eq /drawfill 1 index def {
  98.         aload pop
  99.         /fillblue exch def
  100.         /fillgreen exch def
  101.         /fillred exch def
  102.     }{    pop
  103.     } ifelse
  104. } ifelse
  105. /start exch def
  106. /rotval exch def
  107. /mode exch def
  108. findfont /infont exch def
  109. /printme exch def
  110. /hframe exch def % left on stack by Maker
  111. /wframe exch def % ditto
  112. pop pop    % clean up extra argument passed by Maker
  113. 0 0 moveto
  114. /scaler 12 def % avoid PS rounding problems
  115. infont scaler scalefont setfont
  116. /wpath printme stringwidth pop def
  117. /wfont wframe wpath div scaler mul def
  118. /hpath (X) false charpath flattenpath pathbbox 4 1 roll pop pop pop def
  119. /hfont hframe hpath div scaler mul def
  120. mode /W eq {/hfont wfont def} if
  121. mode /H eq {/wfont hfont def} if
  122. mode /E eq {
  123.   hfont wfont ge {/hfont wfont def} {/wfont hfont def} ifelse
  124. } if
  125. infont [wfont 0 0 hfont 0 0] makefont setfont
  126. newpath 0 0 moveto
  127. start /LR eq {wframe 0 moveto} if
  128. start /UL eq {0 hframe moveto} if
  129. start /UR eq {wframe hframe moveto} if
  130. start /CE eq
  131.  {wframe 2 div hframe 2 div translate
  132.   rotval rotate        % rotate about the mid point
  133.   wframe -2 div hframe -2 div translate 
  134.   wframe wpath wfont mul 12 div sub 2 div 
  135.   hframe hpath hfont mul 12 div sub 2 div moveto} 
  136.  {rotval rotate} ifelse
  137. gsave
  138. thick 0 ge drawline and {
  139.     thick setlinewidth
  140.     linered linegreen lineblue setrgbcolor
  141.     printme false charpath stroke
  142.     grestore
  143.     gsave
  144. } if
  145. drawfill {
  146.     fillred fillgreen fillblue setrgbcolor
  147.     printme show
  148.     grestore
  149. } if
  150. thick 0 lt drawline and {
  151.     thick neg setlinewidth
  152.     linered linegreen lineblue setrgbcolor
  153.     printme false charpath stroke
  154. } if
  155.